import jdk.nashorn.internal.ir.LiteralNode;

import java.util.ArrayList;
import java.util.List;

class Solution228 {

    public List<String> summaryRanges(int[] nums) {
        int len = nums.length ;
        List<String> list = new ArrayList<>() ;
        for(int i=0 ; i < len ; ){
            int left = i ;
            String ret = ""+ nums[left] ;
            int right = i + 1 ;
            while(right < len && nums[right] == nums[right-1]+1){
                right++ ;
            }
            if(right > left + 1){
                ret += "->" + nums[right-1] ;
            }
            list.add(ret) ;
            i = right ;
        }
        return list ;
    }
}